/**
 * Created by yiihua-013 on 16/10/28.
 */

'use strict';

const util = require('util')
const path = require('path')

const koa         = require('koa')
const logger      = require('koa-logger')
const views       = require('koa-views')
const staticCache = require('koa-static-cache')
const Router      = require('koa-router')
const router      = new Router()

var Stats = require('./stats')

let app = koa()

router
    .get('/', function *(next) {
        yield this.render('index')
    })
    .get('/api/stats/memcached',Stats.stats)

app
    .use(logger())
    .use(staticCache(path.join(__dirname, 'static'), {
        maxAge: 365 * 24 * 60 * 60
    }))
    .use(views(__dirname, {
        extension: 'html'
    }))
    .use(router.routes())
    .listen(8080, ()=> {
        util.log('server listening at port 8080')
    })
